import api from './index'
// axios
import request from '@/utils/request'
import qs from "qs";
import { encryptAes, decryptAes, encryptBase64, decryptBase64 } from '@/utils/encryptUtil'

// 登录
export function login(data) {
  console.log("登录信息入参(手机号码+验证码):" + data)
  let encryptStr = encryptAes(JSON.stringify(data))
  //模拟后端返回登录数据
  // return Promise.resolve({"phone":12345678900})
  return request({
    url: api.Login,
    method: 'post',
    data: qs.stringify({ "paramText": encryptStr })
  })
}

export const getVerifyCode = (tel, sfdl) => {
  // debugger
  let param = { tel: tel, sfdl }
  let encryptStr = encryptAes(JSON.stringify(param))
  // console.log("获取验证码信息入参(手机号码):" + param)
  return request({
    url: api.GetVerifyCode,
    method: 'post',
    data: qs.stringify({ "paramText": encryptStr })
  })
}


// 全国公安验证身份证/姓名
export const checkGaIsMatch = (aac002, aac003) => {
  let param = { aac002, aac003 }
  let encryptStr = encryptAes(JSON.stringify(param))
  return request({
    url: api.checkGaIsMatch,
    method: 'post',
    data: qs.stringify({ "paramText": encryptStr })
  })
}

// 获取未读消息
export const getDoctorMsgPag = (param) => {
  let encryptStr = encryptAes(JSON.stringify(param))
  return request({
    url: api.getDoctorMsgPag,
    method: 'post',
    data: qs.stringify({ "paramText": encryptStr })
  })
}

// 将未读消息改为已读
export const readDoctorUserMsg = (id) => {
  let param = { id }
  let encryptStr = encryptAes(JSON.stringify(param))
  return request({
    url: api.readDoctorUserMsg,
    method: 'post',
    data: qs.stringify({ "paramText": encryptStr })
  })
}
